import { createRouter, createWebHashHistory } from 'vue-router'
const Layout = () => import('@/Layout')
const Home = () => import('@/views/Home/index')
const playground = () => import('@/views/playground/index')
const TopCategory = () => import('@/views/category/index')
const CategorySub = () => import('@/views/category/Sub/index')
const MemberLayout = () => import('@/views/Member')
const MemberInfo = () => import('@/views/Member/Info')
const MemberOrder = () => import('@/views/Member/Order')
const Goods = () => import('@/views/Goods/index')
const Login = () => import('@/views/login/index')
const LoginCallBack = () => import('@/views/login/callback')
const Cart = () => import('@/views/cart')
const Settlement = () => import('@/views/Settlement')
const Pay = () => import('@/views/Pay')
const PayCallBack = () => import('@/views/Pay/callback')

const routes = [
  {
    path: '/',
    component: Layout,
    children: [
      { path: '', component: Home },
      { path: '/category/:id', component: TopCategory },
      { path: '/category/sub/:id', component: CategorySub },
      { path: '/goods/:id', component: Goods },
      { path: '/member', component: MemberLayout, children: [{ path: '', component: MemberInfo }, { path: '/order', component: MemberOrder }] },
      { path: '/cart', component: Cart },
      { path: '/settlement', component: Settlement },
      { path: '/pay', component: Pay },
      { path: '/pay/callback', component: PayCallBack }
    ]
  },
  { path: '/login', component: Login },
  { path: '/login/callback', component: LoginCallBack },
  { path: '/play', component: playground }
]

const router = createRouter({
  history: createWebHashHistory(),
  routes
})

export default router
